import React from 'react';
import ReactDOM from 'react-dom';

import {Provider} from 'mobx-react';
import {createHashHistory} from 'history';
import {Router, Route, useRouterHistory} from 'react-router';
import {RouterStore, syncHistoryWithStore} from 'mobx-react-router';

import weaPortalListElement from 'weaPortalListElement';

const browserHistory = useRouterHistory(createHashHistory)({
    queryKey: '_key',
    basename: '/',
});

const routing = new RouterStore();

const allStore = {
    routing,
};

const history = syncHistoryWithStore(browserHistory, allStore.routing);
window.weaHistory = history;

const Root = () => (
    <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@umsirs`} {...allStore}>
        <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@jtso11`} history={history}>
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@07nixh`} path='/' component={props => props.children}>
                {weaPortalListElement.Route}
            </Route>
        </Router>
    </Provider>
);

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@vnyt8q`}/>, document.getElementById('container'));
